<?php

namespace App\Http\Controllers\Admin\Meeting;

use App\Http\Controllers\Admin\BaseController;
use App\Http\Controllers\Controller;
use App\Models\MeetingActivityEnroll;
use Illuminate\Http\Request;

class ActivityEnrollController extends BaseController
{
    /**
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function get(Request $request)
    {
        return ajaxReturn(['enroll'=>MeetingActivityEnroll::find($request->input('id'))]);
    }

    /**
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function batchget(Request $request)
    {
        $query = MeetingActivityEnroll::with(['activity']);
        return ajaxReturn([
            'total'=>$query->count(),
            'items'=>$query->offset($request->input('offset',0))
            ->limit($request->input('count',15))
            ->orderByDesc('id')->get()
        ]);
    }

    /**
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function delete(Request $request)
    {
        MeetingActivityEnroll::whereKey($request->input('items',[]))->delete();
        return ajaxReturn();
    }
}
